import json
from django.http import JsonResponse
from django.shortcuts import render
def login(request):
    body_json = request.body.decode()
    body_dict = json.loads(body_json)
    name = body_dict.get('name')
    pwd = body_dict.get('pwd')
    print(name,pwd)
    if not all([name, pwd]):
        resp = {
            "code": 999,
            "msg": '信息不全'
        }
        return JsonResponse(resp)
    if name == 'zhangsan' and pwd == '1234':
        resp = {
            "code": 0,
            "msg": '登录成功',
            "data": {
                "id": 1,
                "name": '张三',
                "age": 18
            }
        }
        return JsonResponse(resp)
